<div class="layuimini-container">
    <form id="app-form" class="layui-form layuimini-form">

        <div class="layui-form-item">
            <label class="layui-form-label">商品名称</label>
            <div class="layui-input-block">
                <input type="text" name="product_name" class="layui-input" lay-verify="required" placeholder="请输入商品名称" value="{$row.product_name|default=''}">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">选择商品</label>
            <div class="layui-input-block">
                <select name="product_id" lay-verify="required" data-select="{:url('jizhan.activity_product/product_list')}" data-fields="id,store_info" data-value="{$row.product_id|default=''}"
                        lay-search="">
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">选择参与活动</label>
            <div class="layui-input-block">
                <select name="htns_activity_id" lay-verify="required" data-select="{$activityUrl}" data-fields="id,name" data-value="{$row.htns_activity_id|default=''}"
                        lay-search="" lay-filter="cate">
                </select>
            </div>
        </div>
        <div id="position" class="layui-hide">
            <div class="layui-form-item">
                <label class="layui-form-label">是否显示在首页</label>
                <div class="layui-input-block">
                    <input type="radio" name="type" value="" title="否" lay-filter="demo-radio-filter1" {if $row.type eq ''}checked{/if}>
                    <input type="radio" name="type" value="seckill_home" lay-filter="demo-radio-filter1" title="是" {if $row.type eq 'seckill_home'}checked{/if}>
                </div>
            </div>
            <div id="short_title" class="layui-hide">
                <div class="layui-form-item">
                    <label class="layui-form-label">秒杀首页短标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="short_product_name" class="layui-input"  placeholder="请输入秒杀首页短标题" value="{$row.short_product_name|default=''}">
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">选择活动商品分类</label>
            <div class="layui-input-block">
                <select name="cate_id" id="cate_id" lay-verify="required" data-select="{:url('jizhan.activity_product_cate/list')}" data-fields="id,cate_info" data-value="{$row.cate_id|default=''}"
                        lay-search=""  lay-filter="cate">
                </select>
            </div>
        </div>

        <div id="activityTime" class="layui-hide">
            <div class="layui-form-item">
                <label class="layui-form-label">商品活动开始时间</label>
                <div class="layui-input-block">
                    <input type="text" name="start_time" class="layui-input" data-date="" data-date-type="datetime"  placeholder="请输入商品活动开始时间" value="{$row.start_time|default=''}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">商品活动结束时间</label>
                <div class="layui-input-block">
                    <input type="text" name="end_time" class="layui-input" data-date="" data-date-type="datetime" placeholder="请输入商品活动结束时间" value="{$row.end_time|default=''}">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">商品封面图</label>
            <div class="layui-input-block layuimini-upload">
                <input name="image" class="layui-input layui-col-xs6"  placeholder="请上传商品封面图" value="{$row.image|default=''}">
                <div class="layuimini-upload-btn">
                    <span><a class="layui-btn" data-upload="image" data-upload-number="one" data-upload-exts="png|jpg|ico|jpeg" data-upload-icon="image"><i class="fa fa-upload"></i> 上传</a></span>
                    <span><a class="layui-btn layui-btn-normal" id="select_img" data-upload-select="image" data-upload-number="one" data-upload-mimetype="image/*"><i class="fa fa-list"></i> 选择</a></span>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">销售价格</label>
            <div class="layui-input-block">
                <input type="text" name="price" class="layui-input" lay-verify="required" placeholder="请输入销售价格" value="{$row.price|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">划线价格</label>
            <div class="layui-input-block">
                <input type="text" name="ot_price" class="layui-input" lay-verify="required" placeholder="请输入划线价格" value="{$row.ot_price|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">商品描述</label>
            <div class="layui-input-block">
                <input type="text" name="intro" class="layui-input" lay-verify="required" placeholder="请输入商品描述" value="{$row.intro|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">单次购买限量</label>
            <div class="layui-input-block">
                <input type="text" name="one_buy_limit_num" class="layui-input" lay-verify="required" placeholder="请输入单次购买限量" value="{$row.one_buy_limit_num|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">总购买限量</label>
            <div class="layui-input-block">
                <input type="text" name="all_buy_limit_num" class="layui-input" lay-verify="required" placeholder="请输入总购买限量" value="{$row.all_buy_limit_num|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">活动库存量</label>
            <div class="layui-input-block">
                <input type="text" name="stock" class="layui-input" lay-verify="required" placeholder="请输入活动库存量" value="{$row.stock|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-block">
                <input type="text" name="sort" class="layui-input" lay-verify="required" placeholder="请输入排序" value="{$row.sort|default=''}">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <input type="radio" name="status" value="0" title="关闭" lay-filter="demo-radio-filter" {if $row.status eq 0}checked{/if} >
                <input type="radio" name="status" value="1" lay-filter="demo-radio-filter" title="开启" {if $row.status eq 1}checked{/if}>
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注信息</label>
            <div class="layui-input-block">
                <textarea name="remark" class="layui-textarea" placeholder="请输入备注信息">{$row.remark|default=''}</textarea>
            </div>
        </div>

        <div class="hr-line"></div>
        <div class="layui-form-item text-center">
            <button type="submit" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit>确认</button>
            <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">重置</button>
        </div>

    </form>
</div>
<script>
    var activityId = {$activityId};
    console.log('add-activityId:'+activityId);
    layui.use(['form','jquery'], function(){
        var form = layui.form;
        var $ = layui.jquery;

        //各种基于事件的操作，下面会有进一步介绍
        var cate_id = {$row.cate_id};// 默认值
        if(cate_id == 3){
            $('#activityTime').removeClass('layui-hide');
        }else if(cate_id == 7 || cate_id == 8){
            $('#activityTime').removeClass('layui-hide');
            $('#position').removeClass('layui-hide');
        }

        var typeVal = "{$row.type}";// 默认值
        if(typeVal == ''){
            $('#short_title').addClass('layui-hide');
        }else{;
            $('#short_title').removeClass('layui-hide');
        }

        form.on('select(cate)', function(data){
            var selectVal = data.value; //得到被选中的值
            if(selectVal == 3 || selectVal == 5){
                $('#activityTime').removeClass('layui-hide');
            }else{
                $('#activityTime').addClass('layui-hide');
            }
            if(selectVal == 5){
                $('#position').removeClass('layui-hide');
            }else{
                $('#position').addClass('layui-hide');
            }
        });

        form.on('radio(demo-radio-filter1)', function(data){
            var typeVal = data.value; //得到被选中的值
            console.log();
            if(typeVal == ''){
                $('#short_title').addClass('layui-hide');
            }else{
                $('#short_title').removeClass('layui-hide');
            }
        });
    });
</script>